<?php
namespace app\index\controller;

class Pay extends Base
{
    public function index(){

        $user = session('user','','index');
        if(!$user){
            $this->error('请登录','user/login');
        }

        $orderId = input('get.id', 0, 'intval');
        if(empty($orderId)){
            $this->error('该订单不存在');
        }
        $order = model('Order')->get($orderId);
        if(empty($order) || $order->status !=1){
            $this->error('该订单不存在');
        }
        //判断订单是否是用户本人操作
        if($order->username != $user->username){
            $this->error('您没有访问该订单的权限');
        }

        $deal = model('Deal')->get($order->deal_id);
        if(empty($deal)){
            $this->error('订单出错');
        }
        //调取微信支付二维码
        $url = "https://ss0.bdstatic.com/94oJfD_bAAcT8t7mm9GUKT-xh_/timg?image&quality=100&size=b4000_4000&sec=1491616909&di=bafe0140b3b21c478b049fe238f2bd16&src=http://www.duoziwang.com/2016/05/30074208.jpg";

        return $this->fetch('',[
            'deal' => $deal,
            'order' => $order,
            'url' => $url,
        ]);
    }
}
